package code;

/*
 * NewJFrame.java
 *
 * Created on Trečiadienis, 2008, Balandžio 2, 16.36
 */
import java.io.File;
import java.io.IOException;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;

/**
 *
 * @author Mr. Butkus
 */
public class GUI extends javax.swing.JFrame {

private RealMachine rm;
private Kernel kernel;
private Word[] allmemory = new Word[500];
private boolean trace = true;
//      JTable table = new JTable(cellData, columnNames);
final JFileChooser fc = new JFileChooser();

public GUI(RealMachine rm, Kernel kernel)
{
    this.rm = rm;
    this.kernel = kernel;
    initComponents();
}
//---- Fields
//private RealMachine rm;
//private VirtualMachine vm;
//private Word[] allmemory = new Word[RealMachine.RM_U_MEMORY_SIZE + RealMachine.RM_S_MEMORY_SIZE];
//private boolean trace = true;
File file;

/** This method is called from within the constructor to
 * initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        TextPane1 = new javax.swing.JTextPane();
        jScrollPane2 = new javax.swing.JScrollPane();
        TextPane2 = new javax.swing.JTextPane();
        jPanel3 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        TextField6 = new javax.swing.JTextField();
        TextField5 = new javax.swing.JTextField();
        TextField4 = new javax.swing.JTextField();
        TextField3 = new javax.swing.JTextField();
        TextField1 = new javax.swing.JTextField();
        TextField777 = new javax.swing.JTextField();
        TextField888 = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        TextField7 = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        TextField8 = new javax.swing.JTextField();
        TextField9 = new javax.swing.JTextField();
        TextField10 = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        Button2 = new javax.swing.JButton();
        Button1 = new javax.swing.JButton();
        Button3 = new javax.swing.JButton();
        Button4 = new javax.swing.JButton();
        Button6 = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTable = new javax.swing.JTable();
        jPanel2 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        TextField11 = new javax.swing.JTextField();
        TextField12 = new javax.swing.JTextField();
        TextField13 = new javax.swing.JTextField();
        TextField16 = new javax.swing.JTextField();
        TextField14 = new javax.swing.JTextField();
        jPanel5 = new javax.swing.JPanel();
        jLabel21 = new javax.swing.JLabel();
        TextField15 = new javax.swing.JTextField();
        TextField17 = new javax.swing.JTextField();
        jLabel22 = new javax.swing.JLabel();
        Button7 = new javax.swing.JButton();
        jPanel6 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jLabelResource = new javax.swing.JLabel();
        jPanel7 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jLabel23 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("didn't see that comming");
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setFocusCycleRoot(false);
        setResizable(false);

        jPanel1.setName("neimas, doodĄ"); // NOI18N
        jPanel1.setNextFocusableComponent(Button2);

        TextPane1.setEditable(false);
        jScrollPane1.setViewportView(TextPane1);

        TextPane2.setEditable(false);
        jScrollPane2.setViewportView(TextPane2);

        jLabel1.setText("PTR");

        jLabel4.setText("C");

        jLabel3.setText("IP");

        jLabel5.setText("CS");

        jLabel6.setText("DS");

        TextField6.setEditable(false);
        TextField6.setText("jTextField6");

        TextField5.setEditable(false);
        TextField5.setText("jTextField5");

        TextField4.setEditable(false);
        TextField4.setText("jTextField4");

        TextField3.setEditable(false);
        TextField3.setText("jTextField3");

        TextField1.setEditable(false);
        TextField1.setText("jTextField1");

        TextField777.setEditable(false);
        TextField777.setText("todo");
        TextField777.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TextField777ActionPerformed(evt);
            }
        });

        TextField888.setEditable(false);
        TextField888.setText("todo");

        jLabel10.setText("SS");

        jLabel11.setText("SP");

        TextField7.setEditable(false);
        TextField7.setText("jTextField6");

        jLabel12.setText("mode");

        TextField8.setEditable(false);
        TextField8.setText("jTextField6");

        TextField9.setEditable(false);
        TextField9.setText("jTextField6");

        TextField10.setEditable(false);
        TextField10.setText("jTextField6");

        jLabel13.setText("PI");

        jLabel14.setText("SI");

        jLabel15.setText("TI");

        org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jPanel3Layout.createSequentialGroup()
                        .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jLabel1)
                            .add(jLabel3)
                            .add(jLabel4)
                            .add(jLabel5)
                            .add(jLabel6)
                            .add(jLabel11)
                            .add(jLabel10))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jPanel3Layout.createSequentialGroup()
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(TextField4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(TextField5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(TextField6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, TextField777)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, TextField888, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 37, Short.MAX_VALUE))))
                            .add(TextField3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(TextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                    .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                        .add(jPanel3Layout.createSequentialGroup()
                            .add(jLabel15)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                            .add(TextField10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(jPanel3Layout.createSequentialGroup()
                                .add(jLabel14)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                                .add(TextField9, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                            .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                                .add(jPanel3Layout.createSequentialGroup()
                                    .add(jLabel13)
                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                                    .add(TextField8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                                .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel3Layout.createSequentialGroup()
                                    .add(jLabel12)
                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 11, Short.MAX_VALUE)
                                    .add(TextField7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))))
                .addContainerGap(20, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(TextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel1))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel3)
                    .add(TextField3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(6, 6, 6)
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(TextField4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel4))
                .add(6, 6, 6)
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(TextField5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel5))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel3Layout.createSequentialGroup()
                        .add(TextField6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel10)
                            .add(TextField777, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel11)
                            .add(TextField888, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                    .add(jLabel6))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel12)
                    .add(TextField7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(TextField8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel13))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(TextField9, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel14))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(TextField10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel15))
                .addContainerGap(13, Short.MAX_VALUE))
        );

        Button2.setText("Įkrauti programą");
        Button2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Button2ActionPerformed(evt);
            }
        });

        Button1.setText("Vykdyti visą");
        Button1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Button1ActionPerformed(evt);
            }
        });

        Button3.setText("Vykdyti pažingsniui");
        Button3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Button3ActionPerformed(evt);
            }
        });

        Button4.setText("Išeiti");
        Button4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Button4ActionPerformed(evt);
            }
        });

        Button6.setText("Naikinti procesą");
        Button6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Button6ActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel4Layout = new org.jdesktop.layout.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel4Layout.createSequentialGroup()
                        .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                            .add(org.jdesktop.layout.GroupLayout.LEADING, Button3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(org.jdesktop.layout.GroupLayout.LEADING, Button1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(org.jdesktop.layout.GroupLayout.LEADING, Button4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(org.jdesktop.layout.GroupLayout.LEADING, Button2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .add(jPanel4Layout.createSequentialGroup()
                        .add(Button6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(26, 26, 26))))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .add(Button2)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(Button6)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(Button1)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(Button3)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(Button4)
                .addContainerGap())
        );

        jLabel7.setText("Atmintis");

        jLabel8.setText("Išvedimo srautas");

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel7)
                    .add(jPanel1Layout.createSequentialGroup()
                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 116, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jLabel8)
                            .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 116, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .add(18, 18, 18)
                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jPanel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(24, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jLabel7)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel1Layout.createSequentialGroup()
                        .add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 144, Short.MAX_VALUE)
                        .add(jPanel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
                        .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE)
                        .add(18, 18, 18)
                        .add(jLabel8)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 183, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        jLabel9.setFont(new java.awt.Font("SansSerif", 0, 24));
        jLabel9.setText("OS");

        jTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null}
            },
            new String [] {
                "ID", "Prior.", "State", "PTR", "RRRRR", "IP", "C", "CS", "DS", "PI", "SI", "TI", "SS", "SP"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, true, false, false, false, false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane3.setViewportView(jTable);

        jLabel2.setText("Procesų statistika");

        jLabel16.setText("Iš viso");

        jLabel17.setText("Blokuoti");

        jLabel18.setText("Pasiruošę");

        jLabel19.setText("Sustabdyti");

        jLabel20.setText("Vykdomas nr.");

        TextField11.setEditable(false);
        TextField11.setText("jTextField1");

        TextField12.setEditable(false);
        TextField12.setText("jTextField1");

        TextField13.setEditable(false);
        TextField13.setText("jTextField1");

        TextField16.setEditable(false);
        TextField16.setText("jTextField1");

        TextField14.setEditable(false);
        TextField14.setText("jTextField1");

        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel2)
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(jLabel16)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 72, Short.MAX_VALUE)
                        .add(TextField11, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(jLabel17)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 66, Short.MAX_VALUE)
                        .add(TextField12, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(jLabel18)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 57, Short.MAX_VALUE)
                        .add(TextField13, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(jLabel19)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 52, Short.MAX_VALUE)
                        .add(TextField16, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(jLabel20)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 38, Short.MAX_VALUE)
                        .add(TextField14, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .add(jLabel2)
                .add(18, 18, 18)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel16)
                    .add(TextField11, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel17)
                    .add(TextField12, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel18)
                    .add(TextField13, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel19)
                    .add(TextField16, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel20)
                    .add(TextField14, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jLabel21.setText("Įvedimo srautas");

        TextField15.setText("jTextField1");
        TextField15.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TextField15ActionPerformed(evt);
            }
        });

        jLabel22.setText("Naikinamo proceso ID");

        Button7.setText("Įvesti");
        Button7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Button7ActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel5Layout = new org.jdesktop.layout.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel21)
                    .add(jPanel5Layout.createSequentialGroup()
                        .add(TextField15, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(Button7))
                    .add(jLabel22)
                    .add(TextField17, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 61, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(91, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .add(jLabel21)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(TextField15, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(Button7))
                .add(23, 23, 23)
                .add(jLabel22)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(TextField17, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jButton1.setText("Shift tha resource queue left");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabelResource.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabelResource.setText("Resurso eilė");

        org.jdesktop.layout.GroupLayout jPanel6Layout = new org.jdesktop.layout.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel6Layout.createSequentialGroup()
                .add(28, 28, 28)
                .add(jLabelResource, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jButton1)
                .addContainerGap())
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButton1)
                    .add(jLabelResource))
                .addContainerGap(20, Short.MAX_VALUE))
        );

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null},
                {null, null},
                {null, null},
                {null, null}
            },
            new String [] {
                "Failas", "Būsena"
            }
        ));
        jScrollPane4.setViewportView(jTable1);

        jLabel23.setText("Failų sistema");

        org.jdesktop.layout.GroupLayout jPanel7Layout = new org.jdesktop.layout.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel7Layout.createSequentialGroup()
                .add(jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel7Layout.createSequentialGroup()
                        .add(155, 155, 155)
                        .add(jLabel23))
                    .add(jPanel7Layout.createSequentialGroup()
                        .addContainerGap()
                        .add(jScrollPane4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 358, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(168, Short.MAX_VALUE))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel7Layout.createSequentialGroup()
                .add(jLabel23)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jScrollPane4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 107, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(26, 26, 26)
                        .add(jLabel9)
                        .add(278, 278, 278)
                        .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(18, 18, 18)
                        .add(jPanel5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(layout.createSequentialGroup()
                        .addContainerGap()
                        .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(18, 18, 18)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jPanel7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jScrollPane3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 615, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jPanel6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(23, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(jLabel9)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(jScrollPane3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 119, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(18, 18, 18)
                        .add(jPanel7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(18, 18, 18)
                        .add(jPanel6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 136, Short.MAX_VALUE)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jPanel5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                    .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        jPanel1.getAccessibleContext().setAccessibleName("neimas, acc, dood");
        jPanel1.getAccessibleContext().setAccessibleDescription("desc, doodĄ");

        getAccessibleContext().setAccessibleDescription("dood\n");

        pack();
    }// </editor-fold>//GEN-END:initComponents
    private void Button2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Button2ActionPerformed

        int rc = fc.showDialog(null, "Programos pasirinkimas");
        if (rc == JFileChooser.APPROVE_OPTION)
        {
            try
            {
                File filezz = fc.getSelectedFile();
                rm.setFile(filezz.getAbsolutePath());
                rm.setUserProgram(filezz); 
                Button1.setEnabled(true);
                Button3.setEnabled(true);
                Button6.setEnabled(true);
                int nr = kernel.getProcesses().size();
                nr++;
                kernel.createVM(nr);

                kernel.createProcess(nr, 1, (VirtualMachine) kernel.getVMachines().getLast());
                System.out.println("PTR " + rm.getPTR() + "|");
                ((VirtualMachine) kernel.getVMachines().getLast()).loadProgram();

                kernel.saveRegisters((Process) kernel.getProcesses().get(nr - 1));


//            for(int zz = 0; zz < RealMachine.Block_size * 7; zz++)
//            {
//                if(!(FS.wordEmpty(rm.memory[zz])))
//                     System.out.println("RAM "+zz+" "+ rm.wordToHexString(rm.memory[zz]).toString()+"|");
//            }

                showData();
            } catch (IOException ex)
            {
                Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
}//GEN-LAST:event_Button2ActionPerformed

    private void Button3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Button3ActionPerformed
        // Vykdyti pazingsniui
        this.Button2.setEnabled(false);
        if (kernel.isOsComplete())
        {
            this.Button1.setEnabled(false);
            this.Button3.setEnabled(false);
            this.Button6.setEnabled(false);
        }
        if (trace)
        {
            try
            {
                rm.setIP((Integer) 0);
                this.trace = false;
                kernel.grantResource();
                kernel.planner();
                kernel.traceOS();
                showData();
            } catch (IOException ex)
            {
                Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
            }

        } else
        {
            try
            {
                kernel.traceOS();
                showData();
            } catch (IOException ex)
            {
                Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
}//GEN-LAST:event_Button3ActionPerformed

    private void Button1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Button1ActionPerformed
        // Vykdyti viska
            this.Button1.setEnabled(false);//GEN-LAST:event_Button1ActionPerformed

    kernel.planner();
    this.kernel.runOS();
    Button2.setEnabled(false);
   // showData();
    if (kernel.isOsComplete())
    {
        Button1.setEnabled(false);
        Button2.setEnabled(false);
        Button3.setEnabled(false);
        Button6.setEnabled(false);
    }
}

    private void Button4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Button4ActionPerformed
        // Isjungti programa
        System.exit(1);
    }//GEN-LAST:event_Button4ActionPerformed

    private void TextField777ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TextField777ActionPerformed
    // TODO add your handling code here:
}//GEN-LAST:event_TextField777ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // Shift resource queue
        shiftResourceQueue();
        showResourceQueue();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void Button6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Button6ActionPerformed
        try
        {
            String procId = TextField17.getText();
            if (!procId.equals(""))
                kernel.killProcess(Integer.parseInt(procId));//GEN-LAST:event_Button6ActionPerformed
            showData();
        } catch (IOException ex)
        {
            Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
        }
        }

        private void Button7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Button7ActionPerformed
            // input'as
            String input = TextField15.getText();
            
            rm.getInput().add(input);
        }//GEN-LAST:event_Button7ActionPerformed

        private void TextField15ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TextField15ActionPerformed
            // TODO add your handling code here:
        }//GEN-LAST:event_TextField15ActionPerformed

private void showData() throws IOException
{
    String text = null;
    Vector v = rm.getOutput();

    showRegisters();     //isvedam registrus

    for (int i = 0; i < v.size(); i++)
    {
        if (((Word) v.get(i)).a == 0 && ((Word) v.get(i)).b == 0 && ((Word) v.get(i)).c == 0 && ((Word) v.get(i)).d == 0)
            if (i == 0)
                text = ("----" + "\n");
            else
                text += ("----" + "\n");
        else if (i == 0)
            text = (String.valueOf(((Word) v.get(i)).a) + String.valueOf(((Word) v.get(i)).b) + String.valueOf(((Word) v.get(i)).c) + String.valueOf(((Word) v.get(i)).d) + "\n");
        else
            text += (String.valueOf(((Word) v.get(i)).a) + String.valueOf(((Word) v.get(i)).b) + String.valueOf(((Word) v.get(i)).c) + String.valueOf(((Word) v.get(i)).d) + "\n");
    }
    this.TextPane2.setText(text);

    //isvedam atminti
    showMemory();
    showTable();
    showFS();
}

private String getline(int l)
{
    String text = "";
    int g = l;
    if (rm.memory[g].a == 0 && rm.memory[g].b == 0 && rm.memory[g].c == 0 && rm.memory[g].d == 0)
        text += (g + ": " + "----" + "\n");
    else
        text += (g + ": " + rm.memory[g].a + rm.memory[g].b + rm.memory[g].c + rm.memory[g].d + "\n");
    return text;
}

private void showMemory()
{

    String text = null;

    text = "***************\n" + "Vartotojo\n" + "***************\n";

    for (int i = rm.getRealAddress(0); i < (rm.getRealAddress(0) + VirtualMachine.VM_MEMORY_SIZE); i++)
    {
        text += getline(i);
    }

    text += "***************\n" + "PT\n" + "***************\n";
    for (int i = rm.getPTR() * RealMachine.Block_size;
            i < rm.getPTR() * RealMachine.Block_size + VirtualMachine.VM_MEMORY_SIZE / RealMachine.Block_size + 1;
            i++)
    {
        text += getline(i);
    }

    text += "***************\n" + "Stekas\n" + "***************\n";
    for (int i = rm.getSS() + 1;
            i < rm.getSS() + rm.getSP() + 2;
            i++)
    {
        text += getline(i);
    }


    for (int i = RealMachine.RM_U_MEMORY_SIZE; i < (RealMachine.RM_U_MEMORY_SIZE + RealMachine.Block_size / 64); i++)
    {
        if (i == rm.getUMFootprint())
            text += "***************\n" + "Supervizorine\n" + "***************\n";
        text += getline(i);
    }



    this.TextPane1.setText(text);


//    	String text = null;
//    	
//		allmemory = rm.getMemory();
//		
//		text = "***************\n" + "Vartotojo\n" + "***************\n";
//		
//		for (int i = 0; i < (RealMachine.RM_U_MEMORY_SIZE+RealMachine.RM_S_MEMORY_SIZE)/20000; i++){
//			if (i == RealMachine.RM_U_MEMORY_SIZE) text += "***************\n" + "Supervizorine\n" + "***************\n";
//			if (allmemory[i].a == 0 && allmemory[i].b == 0 && allmemory[i].c == 0 && allmemory[i].d == 0){
//				text += (i + ": " + "----" + "\n");
//			}
//			else {
//				text += (i + ": " + allmemory[i].a + allmemory[i].b + allmemory[i].c +  allmemory[i].d + "\n");
//			}
//		}
//		this.TextPane1.setText(text);
}

private void showRegisters()
{
    String bool = null;

    if (rm.getC() == true)
        bool = "1";
    else
        bool = "0";

    this.TextField1.setText(Integer.toString(rm.getPTR()));
    // 	this.TextField2.setText(Short.toString(rm.getR()));
    this.TextField3.setText(Integer.toString(rm.getIP()));
    this.TextField4.setText(bool);
    this.TextField5.setText(Integer.toString(rm.getCS()));
    this.TextField6.setText(Integer.toString(rm.getDS()));
    this.TextField7.setText(String.valueOf(rm.getMODE()));
    this.TextField8.setText(Integer.toString(rm.getPI()));
    this.TextField9.setText(Integer.toString(rm.getSI()));
    this.TextField10.setText(Integer.toString(rm.getTI()));

    this.TextField777.setText(Integer.toString(rm.getSS()));
    this.TextField888.setText(Integer.toString(rm.getSP()));

    this.TextField11.setText(Integer.toString(kernel.getProcesses().size()));
    this.TextField12.setText(Integer.toString(kernel.getBlockedProc().size()));
    this.TextField13.setText(Integer.toString(kernel.getReadyProc().size()));
    this.TextField14.setText(Integer.toString(kernel.getRunProc().getId()));
    this.TextField16.setText(Integer.toString(kernel.getStoppedProc().size()));
}

private void showTable()
{
    int size = kernel.getProcesses().size();

    for (int i = 1; i <= size; i++)
    {
        int id_ = ((Process) kernel.getProcesses().get(i - 1)).getId();
        int prior_ = ((Process) kernel.getProcesses().get(i - 1)).getPriority();
        String state_ = ((Process) kernel.getProcesses().get(i - 1)).getState().toString();
        int regs_ = rm.hexToDec(rm.wordToHexString(((Process) kernel.getProcesses().get(i - 1)).savedRegisters.PTR));
        int ip_ = rm.hexToDec(rm.wordToHexString(((Process) kernel.getProcesses().get(i - 1)).savedRegisters.IP));

        jTable.setValueAt(id_, i, 0);
        jTable.setValueAt(prior_, i, 1);
        jTable.setValueAt(state_, i, 2);
        jTable.setValueAt(regs_, i, 3);
        //jTable.setValueAt(((Process)kernel.getProcesses().get(i-1)).savedRegisters.R,   i, 4);
        jTable.setValueAt(ip_, i, 5);

        boolean c = ((Process) kernel.getProcesses().get(i - 1)).savedRegisters.C;

        if (c)
            jTable.setValueAt("1", i, 6);
        else
            jTable.setValueAt("0", i, 6);


        int cs_ = rm.hexToDec(rm.wordToHexString(((Process) kernel.getProcesses().get(i - 1)).savedRegisters.CS));
        int ds_ = rm.hexToDec(rm.wordToHexString(((Process) kernel.getProcesses().get(i - 1)).savedRegisters.DS));
        int pi_ = ((Process) kernel.getProcesses().get(i - 1)).savedRegisters.PI;
        int si_ = ((Process) kernel.getProcesses().get(i - 1)).savedRegisters.SI;
        int ti_ = ((Process) kernel.getProcesses().get(i - 1)).savedRegisters.TI;
        int ss_ = rm.hexToDec(rm.wordToHexString(((Process) kernel.getProcesses().get(i - 1)).savedRegisters.SS));
        int sp_ = rm.hexToDec(rm.wordToHexString(((Process) kernel.getProcesses().get(i - 1)).savedRegisters.SP));

        jTable.setValueAt(cs_, i, 7);
        jTable.setValueAt(ds_, i, 8);
        jTable.setValueAt(pi_, i, 9);
        jTable.setValueAt(si_, i, 10);
        jTable.setValueAt(ti_, i, 11);
        jTable.setValueAt(ss_, i, 12);
        jTable.setValueAt(sp_, i, 13);

    }
    for (int x = size + 1; x <= 5; x++)
    {
        for (int i = 0; i <= 11; i++)
        {
            jTable.setValueAt("", x, i);
        }
    }
//table.updateUI();


}

private void showResourceQueue()
{
    String text = "";
    for (int i = 0; i < kernel.getBlockedProc().size(); i++)
    {
        text += ((Process) kernel.getBlockedProc().get(i)).getId() + "; ";
    }
    jLabelResource.setText(text);
}

private void shiftResourceQueue()
{
    if(kernel.getBlockedProc().size() > 1)
         kernel.getBlockedProc().addLast(kernel.getBlockedProc().pollFirst());
}

private void showFS() throws IOException
{
    Vector[] stuff = new Vector[2];
    stuff = rm.fs.getAllFilenames();

    class trueToOpenFalseToClosed 
    {
        public String doit(String state)
        {
            if (state.compareToIgnoreCase("true") == 0)
                return "Atidarytas";
            else
                return "Uždarytas";
        }
    }
    
    trueToOpenFalseToClosed converter = new trueToOpenFalseToClosed();

    for (int i = 0; i < stuff[0].size(); i++)
    {
        jTable1.setValueAt(stuff[0].get(i).toString(), i, 0);
        jTable1.setValueAt(converter.doit(stuff[1].get(i).toString()) , i, 1);
    // System.out.println("name"+stuff[0].get(i).toString()+"name");
    // System.out.println("state"+stuff[1].get(i).toString()+"state");
    }

}
/**
 * @param args the command line arguments
 */
/*
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new GUI().setVisible(true);
}
});
}
 */
    // Variables declaration - do not modify//GEN-BEGIN:variables
    javax.swing.JButton Button1;
    javax.swing.JButton Button2;
    javax.swing.JButton Button3;
    javax.swing.JButton Button4;
    javax.swing.JButton Button6;
    javax.swing.JButton Button7;
    javax.swing.JTextField TextField1;
    javax.swing.JTextField TextField10;
    javax.swing.JTextField TextField11;
    javax.swing.JTextField TextField12;
    javax.swing.JTextField TextField13;
    javax.swing.JTextField TextField14;
    javax.swing.JTextField TextField15;
    javax.swing.JTextField TextField16;
    javax.swing.JTextField TextField17;
    javax.swing.JTextField TextField3;
    javax.swing.JTextField TextField4;
    javax.swing.JTextField TextField5;
    javax.swing.JTextField TextField6;
    javax.swing.JTextField TextField7;
    javax.swing.JTextField TextField777;
    javax.swing.JTextField TextField8;
    javax.swing.JTextField TextField888;
    javax.swing.JTextField TextField9;
    javax.swing.JTextPane TextPane1;
    javax.swing.JTextPane TextPane2;
    javax.swing.JButton jButton1;
    javax.swing.JLabel jLabel1;
    javax.swing.JLabel jLabel10;
    javax.swing.JLabel jLabel11;
    javax.swing.JLabel jLabel12;
    javax.swing.JLabel jLabel13;
    javax.swing.JLabel jLabel14;
    javax.swing.JLabel jLabel15;
    javax.swing.JLabel jLabel16;
    javax.swing.JLabel jLabel17;
    javax.swing.JLabel jLabel18;
    javax.swing.JLabel jLabel19;
    javax.swing.JLabel jLabel2;
    javax.swing.JLabel jLabel20;
    javax.swing.JLabel jLabel21;
    javax.swing.JLabel jLabel22;
    javax.swing.JLabel jLabel23;
    javax.swing.JLabel jLabel3;
    javax.swing.JLabel jLabel4;
    javax.swing.JLabel jLabel5;
    javax.swing.JLabel jLabel6;
    javax.swing.JLabel jLabel7;
    javax.swing.JLabel jLabel8;
    javax.swing.JLabel jLabel9;
    javax.swing.JLabel jLabelResource;
    javax.swing.JPanel jPanel1;
    javax.swing.JPanel jPanel2;
    javax.swing.JPanel jPanel3;
    javax.swing.JPanel jPanel4;
    javax.swing.JPanel jPanel5;
    javax.swing.JPanel jPanel6;
    javax.swing.JPanel jPanel7;
    javax.swing.JScrollPane jScrollPane1;
    javax.swing.JScrollPane jScrollPane2;
    javax.swing.JScrollPane jScrollPane3;
    javax.swing.JScrollPane jScrollPane4;
    javax.swing.JTable jTable;
    javax.swing.JTable jTable1;
    // End of variables declaration//GEN-END:variables
}
